<template>
    <div class="module-wrap">
      <div class="tool-row">
        <el-button size="small" type="primary" @click="openCreateOrder">新增工单</el-button>
        <el-input v-model="kw" placeholder="搜索工单号/内容" clearable style="width:240px"/>
      </div>
  
      <el-table :data="filtered" border stripe height="520">
        <el-table-column prop="orderNo" label="工单号" width="160"/>
        <el-table-column prop="date"    label="工单日期" width="140"/>
        <el-table-column prop="title"   label="工单内容"/>
        <el-table-column prop="work"    label="作业内容" />
        <el-table-column prop="debug"   label="完成调试数据" />
        <el-table-column label="操作" width="180">
          <template #default="{row}">
            <el-button link size="small" type="primary" @click="$emit('open-detail', row)">详情</el-button>
            <el-button link size="small" @click="editOrder(row)">编辑</el-button>
            <el-button link size="small" type="danger" @click="removeOrder(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </template>
  
  <script setup>
  import {ref,computed} from 'vue';
  const props = defineProps({ mother:Object });
  const kw = ref('');
  const orders = ref([]); // 后端：按 mother.id 拉取工单列表
  const filtered = computed(()=>{
    const k=(kw.value||'').toLowerCase();
    if(!k) return orders.value;
    return orders.value.filter(o=> (o.orderNo+o.title+o.work).toLowerCase().includes(k));
  });
  function openCreateOrder(){ /* 新增工单弹窗 */ }
  function editOrder(o){ /* 编辑工单 */ }
  function removeOrder(o){ /* 删除后刷新 */ }
  </script>
  
  <style scoped>
  .module-wrap{ display:grid; gap:12px; }
  .tool-row{ display:flex; gap:8px; }
  </style>
  